package com.threeCountry;

/**
 * Created by yijy on 2017/5/31.
 */
public class Actor extends Thread {

    @Override
    public void run() {
        System.out.println(getName()+"是一个演员！");
        int count=0;
        boolean keeprun=true;
        while(keeprun){
            System.out.println(getName()+"登台演出："+(++count));
            if(count==100){
                keeprun=false;
            }

            if(count%10==0){
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }
        System.out.println(getName()+"的演出结束！");
    }

    public static void main(String[] args) {
        Thread actor = new Actor();
        actor.setName("Mr.Thread");
        actor.start();

        Thread actrecess = new Thread(new Actrecess(),"Mr.Runnable");
        actrecess.start();
    }
}

class Actrecess implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"是一个演员！");
        int count=0;
        boolean keeprun=true;
        while(keeprun){
            System.out.println(Thread.currentThread().getName()+"登台演出："+(++count));
            if(count==100){
                keeprun=false;
            }

            if(count%10==0){
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }
        System.out.println(Thread.currentThread().getName()+"的演出结束！");
    }
}
